# kinds                                                               -*- sh -*-
#
# For documentation on this file format, please refer to
# src/theory/builtin/kinds.
#

theory THEORY_BAGS \
    ::cvc5::internal::theory::bags::TheoryBags \
    "theory/bags/theory_bags.h"
typechecker "theory/bags/theory_bags_type_rules.h"
rewriter ::cvc5::internal::theory::bags::BagsRewriter \
    "theory/bags/bags_rewriter.h"

properties parametric
properties check presolve

# constants
constant BAG_EMPTY \
    class \
    EmptyBag \
    ::cvc5::internal::EmptyBagHashFunction \
    "expr/emptybag.h" \
    "the empty bag constant; payload is an instance of the cvc5::internal::EmptyBag class"

# the type
operator BAG_TYPE 1 "bag type, takes as parameter the type of the elements"
cardinality BAG_TYPE \
    "::cvc5::internal::theory::bags::BagsProperties::computeCardinality(%TYPE%)" \
    "theory/bags/theory_bags_type_rules.h"
well-founded BAG_TYPE \
    "::cvc5::internal::theory::bags::BagsProperties::isWellFounded(%TYPE%)" \
    "::cvc5::internal::theory::bags::BagsProperties::mkGroundTerm(%TYPE%)" \
    "theory/bags/theory_bags_type_rules.h"
enumerator BAG_TYPE \
    "::cvc5::internal::theory::bags::BagEnumerator" \
    "theory/bags/theory_bags_type_enumerator.h"

# operators
operator BAG_UNION_MAX         2  "union for bags (max)"
operator BAG_UNION_DISJOINT    2  "disjoint union for bags (sum)"
operator BAG_INTER_MIN         2  "bag intersection (min)"

# {|("a", 2), ("b", 3)} \ {("a", 1)|} = {|("a", 1), ("b", 3)|}
operator BAG_DIFFERENCE_SUBTRACT    2  "bag difference1 (subtracts multiplicities)"

# {|("a", 2), ("b", 3)} \\ {("a", 1)|} = {|("b", 3)|}
operator BAG_DIFFERENCE_REMOVE 2  "bag difference remove (removes shared elements)"

operator BAG_SUBBAG  2  "inclusion predicate for bags (less than or equal multiplicities)"
operator BAG_COUNT   2  "multiplicity of an element in a bag"
operator BAG_MEMBER  2  "bag membership predicate; is first parameter a member of second?"
operator BAG_SETOF   1  "eliminate duplicates in a bag (also known as the delta operator,or the squash operator)"

operator BAG_MAKE    2 "constructs a bag from one element along with its multiplicity"

operator BAG_CARD          1  "bag cardinality operator"

# The operator choose returns an element from a given bag.
# If bag A = {("a", 1)}, then the term (choose A) is equivalent to the term a.
# If the bag is empty, then (choose A) is an arbitrary value.
# If the bag has cardinality > 1, then (choose A) will deterministically return an element in A.
operator BAG_CHOOSE        1  "return an element in the bag given as a parameter"

# The bag.map operator applies the first argument, a function of type (-> T1 T2), to every element
# of the second argument, a bag of type (Bag T1), and returns a bag of type (Bag T2).
operator BAG_MAP           2  "bag map function"

# The bag.filter operator takes a predicate of type (-> T Bool) and a bag of type (Bag T)
# and returns the same bag excluding those elements that do not satisfy the predicate
operator BAG_FILTER        2  "bag filter operator"

# bag.fold operator combines elements of a bag into a single value.
# (bag.fold f t B) folds the elements of bag B starting with term t and using
# the combining function f.
#  f: a binary operation of type (-> T1 T2 T2)
#  t: an initial value of type T2
#  B: a bag of type (Bag T1)
operator BAG_FOLD          3  "bag fold operator"

# bag.partition operator partitions a bag into a bag of bags based on an equivalence relation such that
# each element occurs exactly in one these bags.
operator BAG_PARTITION     2 "bag partition operator"

typerule BAG_UNION_MAX           ::cvc5::internal::theory::bags::BinaryOperatorTypeRule
typerule BAG_UNION_DISJOINT      ::cvc5::internal::theory::bags::BinaryOperatorTypeRule
typerule BAG_INTER_MIN           ::cvc5::internal::theory::bags::BinaryOperatorTypeRule
typerule BAG_DIFFERENCE_SUBTRACT ::cvc5::internal::theory::bags::BinaryOperatorTypeRule
typerule BAG_DIFFERENCE_REMOVE   ::cvc5::internal::theory::bags::BinaryOperatorTypeRule
typerule BAG_SUBBAG              ::cvc5::internal::theory::bags::SubBagTypeRule
typerule BAG_COUNT               ::cvc5::internal::theory::bags::CountTypeRule
typerule BAG_MEMBER              ::cvc5::internal::theory::bags::MemberTypeRule
typerule BAG_SETOF   ::cvc5::internal::theory::bags::SetofTypeRule
typerule BAG_MAKE                ::cvc5::internal::theory::bags::BagMakeTypeRule
typerule BAG_EMPTY               ::cvc5::internal::theory::bags::EmptyBagTypeRule
typerule BAG_CARD                ::cvc5::internal::theory::bags::CardTypeRule
typerule BAG_CHOOSE              ::cvc5::internal::theory::bags::ChooseTypeRule
typerule BAG_MAP                 ::cvc5::internal::theory::bags::BagMapTypeRule
typerule BAG_FILTER              ::cvc5::internal::theory::bags::BagFilterTypeRule
typerule BAG_FOLD                ::cvc5::internal::theory::bags::BagFoldTypeRule
typerule BAG_PARTITION           ::cvc5::internal::theory::bags::BagPartitionTypeRule

construle BAG_UNION_DISJOINT     ::cvc5::internal::theory::bags::BinaryOperatorTypeRule
construle BAG_MAKE               ::cvc5::internal::theory::bags::BagMakeTypeRule


# table.product operator returns the cross product of two tables
operator TABLE_PRODUCT             2 "table cross product"

# table.project operator extends datatypes tuple_project operator to a bag of tuples
constant TABLE_PROJECT_OP \
  class \
  ProjectOp+ \
  ::cvc5::internal::ProjectOpHashFunction \
  "theory/datatypes/project_op.h" \
  "operator for TABLE_PROJECT; payload is an instance of the cvc5::internal::ProjectOp class"

parameterized TABLE_PROJECT TABLE_PROJECT_OP 1 "table projection"

# table.aggregate operator
constant TABLE_AGGREGATE_OP \
  class \
  ProjectOp+ \
  ::cvc5::internal::ProjectOpHashFunction \
  "theory/datatypes/project_op.h" \
  "operator for TABLE_AGGREGATE; payload is an instance of the cvc5::internal::ProjectOp class"

parameterized TABLE_AGGREGATE TABLE_AGGREGATE_OP 3 "table aggregate"

# table.join operator
constant TABLE_JOIN_OP \
  class \
  ProjectOp+ \
  ::cvc5::internal::ProjectOpHashFunction \
  "theory/datatypes/project_op.h" \
  "operator for TABLE_JOIN; payload is an instance of the cvc5::internal::ProjectOp class"

parameterized TABLE_JOIN TABLE_JOIN_OP 2 "table join"

# table.group operator
constant TABLE_GROUP_OP \
  class \
  ProjectOp+ \
  ::cvc5::internal::ProjectOpHashFunction \
  "theory/datatypes/project_op.h" \
  "operator for TABLE_GROUP; payload is an instance of the cvc5::internal::ProjectOp class"

parameterized TABLE_GROUP TABLE_GROUP_OP 1 "table group"

typerule TABLE_PRODUCT              ::cvc5::internal::theory::bags::TableProductTypeRule
typerule TABLE_PROJECT_OP           "SimpleTypeRule<RBuiltinOperator>"
typerule TABLE_PROJECT              ::cvc5::internal::theory::bags::TableProjectTypeRule
typerule TABLE_AGGREGATE_OP         "SimpleTypeRule<RBuiltinOperator>"
typerule TABLE_AGGREGATE            ::cvc5::internal::theory::bags::TableAggregateTypeRule
typerule TABLE_JOIN_OP              "SimpleTypeRule<RBuiltinOperator>"
typerule TABLE_JOIN                 ::cvc5::internal::theory::bags::TableJoinTypeRule
typerule TABLE_GROUP_OP             "SimpleTypeRule<RBuiltinOperator>"
typerule TABLE_GROUP                ::cvc5::internal::theory::bags::TableGroupTypeRule

endtheory
